//
//  ViewController.m
//  FMDBDemo
//
//  Created by 赵成峰 on 2016/10/12.
//  Copyright © 2016年 赵成峰youdaoli. All rights reserved.
//

#import "ViewController.h"
#import "FMDBManager.h"
#import "Student.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UIButton *button1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 200, 100, 100)];
    button1.backgroundColor = [UIColor redColor];
    button1.tag = 100;
    [button1 addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
}

- (void)buttonClicked:(UIButton *)button {
    
    if (button.tag == 100) {
        [Student readData];
        return;
    }
    
    Student *student = [[Student alloc] init];
    student.name = @"ah";
    student.sex = @"M";
    student.age = 14;
    
    [student save];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
